﻿namespace Hardcodet.Wpf.TaskbarNotification
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Controls.Primitives;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Threading;

    public class TaskbarIcon : FrameworkElement, IDisposable
    {
        public const string a = "NotifyIcon";
        public static readonly RoutedEvent aa = EventManager.RegisterRoutedEvent("TrayMouseDoubleClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ab = EventManager.RegisterRoutedEvent("TrayMouseMove", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ac = EventManager.RegisterRoutedEvent("TrayBalloonTipShown", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ad = EventManager.RegisterRoutedEvent("TrayBalloonTipClosed", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ae = EventManager.RegisterRoutedEvent("TrayBalloonTipClicked", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent af = EventManager.RegisterRoutedEvent("TrayContextMenuOpen", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ag = EventManager.RegisterRoutedEvent("PreviewTrayContextMenuOpen", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ah = EventManager.RegisterRoutedEvent("TrayPopupOpen", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ai = EventManager.RegisterRoutedEvent("PreviewTrayPopupOpen", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent aj = EventManager.RegisterRoutedEvent("TrayToolTipOpen", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ak = EventManager.RegisterRoutedEvent("PreviewTrayToolTipOpen", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent al = EventManager.RegisterRoutedEvent("TrayToolTipClose", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent am = EventManager.RegisterRoutedEvent("PreviewTrayToolTipClose", RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent an = EventManager.RegisterRoutedEvent("PopupOpened", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ao = EventManager.RegisterRoutedEvent("ToolTipOpened", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ap = EventManager.RegisterRoutedEvent("ToolTipClose", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent aq = EventManager.RegisterRoutedEvent("BalloonShowing", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent ar = EventManager.RegisterRoutedEvent("BalloonClosing", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly DependencyProperty @as = DependencyProperty.RegisterAttached("ParentTaskbarIcon", typeof(TaskbarIcon), typeof(TaskbarIcon));
        private f at;
        private readonly d au = (Util.b() ? d.b() : new d(j.a));
        private Action av;
        private readonly Timer aw;
        private readonly Timer ax;
        [CompilerGenerated]
        private bool ay;
        [CompilerGenerated]
        private bool az;
        private static readonly DependencyPropertyKey b = DependencyProperty.RegisterReadOnly("TrayPopupResolved", typeof(Popup), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty c = b.DependencyProperty;
        private static readonly DependencyPropertyKey d = DependencyProperty.RegisterReadOnly("TrayToolTipResolved", typeof(ToolTip), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty e = d.DependencyProperty;
        private static readonly DependencyPropertyKey f = DependencyProperty.RegisterReadOnly("CustomBalloon", typeof(Popup), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty g = f.DependencyProperty;
        private System.Drawing.Icon h;
        public static readonly DependencyProperty i = DependencyProperty.Register("IconSource", typeof(ImageSource), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(TaskbarIcon.g)));
        public static readonly DependencyProperty j = DependencyProperty.Register("ToolTipText", typeof(string), typeof(TaskbarIcon), new FrameworkPropertyMetadata(string.Empty, new PropertyChangedCallback(TaskbarIcon.f)));
        public static readonly DependencyProperty k = DependencyProperty.Register("TrayToolTip", typeof(UIElement), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(TaskbarIcon.e)));
        public static readonly DependencyProperty l = DependencyProperty.Register("TrayPopup", typeof(UIElement), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(TaskbarIcon.d)));
        public static readonly DependencyProperty m = DependencyProperty.Register("MenuActivation", typeof(PopupActivationMode), typeof(TaskbarIcon), new FrameworkPropertyMetadata(PopupActivationMode.RightClick));
        public static readonly DependencyProperty n = DependencyProperty.Register("PopupActivation", typeof(PopupActivationMode), typeof(TaskbarIcon), new FrameworkPropertyMetadata(PopupActivationMode.LeftClick));
        public static readonly DependencyProperty o = DependencyProperty.Register("DoubleClickCommand", typeof(ICommand), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty p = DependencyProperty.Register("DoubleClickCommandParameter", typeof(object), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty q = DependencyProperty.Register("DoubleClickCommandTarget", typeof(IInputElement), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty r = DependencyProperty.Register("LeftClickCommand", typeof(ICommand), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty s = DependencyProperty.Register("LeftClickCommandParameter", typeof(object), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly DependencyProperty t = DependencyProperty.Register("LeftClickCommandTarget", typeof(IInputElement), typeof(TaskbarIcon), new FrameworkPropertyMetadata(null));
        public static readonly RoutedEvent u = EventManager.RegisterRoutedEvent("TrayLeftMouseDown", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent v = EventManager.RegisterRoutedEvent("TrayRightMouseDown", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent w = EventManager.RegisterRoutedEvent("TrayMiddleMouseDown", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent x = EventManager.RegisterRoutedEvent("TrayLeftMouseUp", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent y = EventManager.RegisterRoutedEvent("TrayRightMouseUp", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
        public static readonly RoutedEvent z = EventManager.RegisterRoutedEvent("TrayMiddleMouseUp", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));

        static TaskbarIcon()
        {
            PropertyMetadata typeMetadata = new PropertyMetadata(Visibility.Visible, new PropertyChangedCallback(TaskbarIcon.c));
            UIElement.VisibilityProperty.OverrideMetadata(typeof(TaskbarIcon), typeMetadata);
            typeMetadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(TaskbarIcon.b));
            FrameworkElement.DataContextProperty.OverrideMetadata(typeof(TaskbarIcon), typeMetadata);
            typeMetadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(TaskbarIcon.a));
            FrameworkElement.ContextMenuProperty.OverrideMetadata(typeof(TaskbarIcon), typeMetadata);
        }

        public TaskbarIcon()
        {
            this.at = f.p(this.au.f());
            this.d();
            this.au.b(new Action<c>(this.a));
            this.au.a(new Action(this.e));
            this.au.c(new Action<bool>(this.d));
            this.au.d(new Action<bool>(this.c));
            this.aw = new Timer(new TimerCallback(this.a));
            this.ax = new Timer(new TimerCallback(this.b));
            if (Application.Current != null)
            {
                Application.Current.Exit += new ExitEventHandler(this.OnExit);
            }
        }

        [CompilerGenerated]
        private void a()
        {
            this.ae().a(this.aw(), this.v() ?? this);
        }

        private void a(c A_0)
        {
            Action action = null;
            Action action2 = null;
            Action action3 = null;
            i a;
            if (!this.an())
            {
                <>c__DisplayClasse classe;
                switch (A_0)
                {
                    case c.a:
                        this.ac();
                        return;

                    case c.b:
                        this.ah();
                        break;

                    case c.c:
                        this.at();
                        break;

                    case c.d:
                        this.ad();
                        break;

                    case c.e:
                        this.ao();
                        break;

                    case c.f:
                        this.q();
                        break;

                    case c.g:
                        this.ag();
                        break;

                    case c.h:
                        this.aw.Change(-1, -1);
                        this.n();
                        break;

                    case c.i:
                        this.aq();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("me", "Missing handler for mouse event flag: " + A_0);
                }
                a = new i();
                o.GetCursorPos(ref a);
                bool flag = false;
                if (A_0.a(this.al()))
                {
                    if (A_0 == c.e)
                    {
                        if (action == null)
                        {
                            action = new Action(classe.c);
                        }
                        this.av = action;
                        this.aw.Change(o.GetDoubleClickTime(), -1);
                        flag = true;
                    }
                    else
                    {
                        this.b(a);
                    }
                }
                if (A_0.a(this.am()))
                {
                    if (A_0 == c.e)
                    {
                        if (action2 == null)
                        {
                            action2 = new Action(classe.d);
                        }
                        this.av = action2;
                        this.aw.Change(o.GetDoubleClickTime(), -1);
                        flag = true;
                    }
                    else
                    {
                        this.a(a);
                    }
                }
                if ((A_0 == c.e) && !flag)
                {
                    if (action3 == null)
                    {
                        action3 = new Action(this.a);
                    }
                    this.av = action3;
                    this.aw.Change(o.GetDoubleClickTime(), -1);
                }
            }
        }

        private void a(i A_0)
        {
            if ((!this.an() && !this.ai().Handled) && (base.ContextMenu != null))
            {
                base.ContextMenu.Placement = PlacementMode.AbsolutePoint;
                base.ContextMenu.HorizontalOffset = A_0.a;
                base.ContextMenu.VerticalOffset = A_0.b;
                base.ContextMenu.IsOpen = true;
                o.SetForegroundWindow(this.au.f());
                this.t();
            }
        }

        private void a(bool A_0)
        {
            if (!this.an() && A_0)
            {
                lock (this)
                {
                    this.b(true);
                    Application.Current.Exit -= new ExitEventHandler(this.OnExit);
                    this.aw.Dispose();
                    this.ax.Dispose();
                    this.au.Dispose();
                    this.c();
                }
            }
        }

        private void a(object A_0)
        {
            if (!this.an())
            {
                Action av = this.av;
                if (av != null)
                {
                    this.av = null;
                    Application.Current.Dispatcher.Invoke(av, new object[0]);
                }
            }
        }

        protected void a(Popup A_0)
        {
            base.SetValue(f, A_0);
        }

        protected void a(ToolTip A_0)
        {
            base.SetValue(d, A_0);
        }

        public static TaskbarIcon a(DependencyObject A_0)
        {
            return (TaskbarIcon) A_0.GetValue(@as);
        }

        private void a(DependencyPropertyChangedEventArgs A_0)
        {
            if (A_0.OldValue != null)
            {
                a((DependencyObject) A_0.OldValue, (TaskbarIcon) null);
            }
            if (A_0.NewValue != null)
            {
                a((DependencyObject) A_0.NewValue, this);
            }
            this.a((ContextMenu) A_0.NewValue, null, base.DataContext);
        }

        public void a(RoutedEventHandler A_0)
        {
            base.RemoveHandler(z, A_0);
        }

        public static void a(DependencyObject A_0, TaskbarIcon A_1)
        {
            A_0.SetValue(@as, A_1);
        }

        private static void a(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
        {
            ((TaskbarIcon) A_0).a(A_1);
        }

        public static void a(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.a(A_0, ar, A_1);
        }

        public void a(string A_0, string A_1, BalloonIcon A_2)
        {
            lock (this)
            {
                this.a(A_0, A_1, A_2.a(), IntPtr.Zero);
            }
        }

        public void a(string A_0, string A_1, System.Drawing.Icon A_2)
        {
            if (A_2 == null)
            {
                throw new ArgumentNullException("customIcon");
            }
            lock (this)
            {
                this.a(A_0, A_1, l.e, A_2.Handle);
            }
        }

        private void a(FrameworkElement A_0, object A_1, object A_2)
        {
            if (((A_0 != null) && !A_0.a()) && (object.ReferenceEquals(this, A_0.DataContext) || object.Equals(A_1, A_0.DataContext)))
            {
                A_0.DataContext = A_2 ?? this;
            }
        }

        public void a(UIElement A_0, PopupAnimation A_1, int? A_2)
        {
            Action action2 = null;
            UIElement b = A_0;
            PopupAnimation c = A_1;
            int? d = A_2;
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                if (action2 == null)
                {
                    <>c__DisplayClass4 class2;
                    action2 = new Action(class2.e);
                }
                Action method = action2;
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, method);
            }
            else
            {
                if (b == null)
                {
                    throw new ArgumentNullException("balloon");
                }
                if (d.HasValue && (d < 500))
                {
                    string format = "Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms";
                    format = string.Format(format, d);
                    throw new ArgumentOutOfRangeException("timeout", format);
                }
                this.b();
                lock (this)
                {
                    this.r();
                }
                Popup popup = new Popup {
                    AllowsTransparency = true
                };
                this.a(popup, null, base.DataContext);
                popup.PopupAnimation = c;
                popup.Child = b;
                popup.Placement = PlacementMode.AbsolutePoint;
                popup.StaysOpen = true;
                i i = n.a();
                popup.HorizontalOffset = i.a - 1;
                popup.VerticalOffset = i.b - 1;
                lock (this)
                {
                    this.a(popup);
                }
                a(b, this);
                TaskbarIcon.c(b, this);
                popup.IsOpen = true;
                if (d.HasValue)
                {
                    this.ax.Change(d.Value, -1);
                }
            }
        }

        private void a(string A_0, string A_1, l A_2, IntPtr A_3)
        {
            this.b();
            this.at.j = A_1 ?? string.Empty;
            this.at.l = A_0 ?? string.Empty;
            this.at.m = A_2;
            this.at.o = A_3;
            Util.a(ref this.at, q.b, g.e | g.b);
        }

        public void aa(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ak, A_0);
        }

        public void ab(RoutedEventHandler A_0)
        {
            base.AddHandler(am, A_0);
        }

        protected RoutedEventArgs ac()
        {
            return p(this);
        }

        public void ac(RoutedEventHandler A_0)
        {
            base.AddHandler(v, A_0);
        }

        protected RoutedEventArgs ad()
        {
            return s(this);
        }

        public void ad(RoutedEventHandler A_0)
        {
            base.AddHandler(u, A_0);
        }

        public void ae(RoutedEventHandler A_0)
        {
            base.RemoveHandler(v, A_0);
        }

        protected RoutedEventArgs af()
        {
            return e(this);
        }

        public void af(RoutedEventHandler A_0)
        {
            base.RemoveHandler(am, A_0);
        }

        protected RoutedEventArgs ag()
        {
            return r(this);
        }

        public void ag(RoutedEventHandler A_0)
        {
            base.AddHandler(al, A_0);
        }

        protected RoutedEventArgs ah()
        {
            return v(this);
        }

        public void ah(RoutedEventHandler A_0)
        {
            base.AddHandler(y, A_0);
        }

        protected RoutedEventArgs ai()
        {
            return k(this);
        }

        public void ai(RoutedEventHandler A_0)
        {
            base.RemoveHandler(al, A_0);
        }

        public void aj(RoutedEventHandler A_0)
        {
            base.RemoveHandler(u, A_0);
        }

        public void ak(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ai, A_0);
        }

        public void al(RoutedEventHandler A_0)
        {
            base.AddHandler(ab, A_0);
        }

        protected RoutedEventArgs ao()
        {
            return t(this);
        }

        protected RoutedEventArgs aq()
        {
            return m(this);
        }

        protected RoutedEventArgs @as()
        {
            return i(this);
        }

        protected RoutedEventArgs at()
        {
            return w(this);
        }

        public void av()
        {
            if (!this.an())
            {
                lock (this)
                {
                    this.ax.Change(-1, -1);
                }
            }
        }

        protected RoutedEventArgs ay()
        {
            return h(this);
        }

        private void b()
        {
            if (this.an())
            {
                throw new ObjectDisposedException(base.Name ?? base.GetType().FullName);
            }
        }

        private void b(i A_0)
        {
            if ((!this.an() && !this.@as().Handled) && (this.ab() != null))
            {
                this.ar().Placement = PlacementMode.AbsolutePoint;
                this.ar().HorizontalOffset = A_0.a;
                this.ar().VerticalOffset = A_0.b;
                this.ar().IsOpen = true;
                o.SetForegroundWindow(this.au.f());
                if (this.ab() != null)
                {
                    d((DependencyObject) this.ab());
                }
                this.k();
            }
        }

        private void b(object A_0)
        {
            if (!this.an())
            {
                Action method = new Action(this.r);
                Application.Current.Dispatcher.Invoke(method, new object[0]);
            }
        }

        protected void b(Popup A_0)
        {
            base.SetValue(b, A_0);
        }

        internal static RoutedEventArgs b(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ap
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private void b(DependencyPropertyChangedEventArgs A_0)
        {
            object newValue = A_0.NewValue;
            object oldValue = A_0.OldValue;
            this.a(this.ar(), oldValue, newValue);
            this.a(this.au(), oldValue, newValue);
            this.a(base.ContextMenu, oldValue, newValue);
        }

        public void b(RoutedEventHandler A_0)
        {
            base.AddHandler(ak, A_0);
        }

        internal static RoutedEventArgs b(DependencyObject A_0, TaskbarIcon A_1)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs(ar, A_1);
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private static void b(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
        {
            ((TaskbarIcon) A_0).b(A_1);
        }

        public static void b(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.b(A_0, ar, A_1);
        }

        private void c()
        {
            lock (this)
            {
                if (this.aj())
                {
                    Util.a(ref this.at, q.c, g.a);
                    this.e(false);
                }
            }
        }

        private void c(bool A_0)
        {
            if (A_0)
            {
                this.p();
            }
            else
            {
                this.u();
            }
        }

        internal static RoutedEventArgs c(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ao
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private void c(DependencyPropertyChangedEventArgs A_0)
        {
            if (((Visibility) A_0.NewValue) == Visibility.Visible)
            {
                this.d();
            }
            else
            {
                this.c();
            }
        }

        public void c(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ac, A_0);
        }

        internal static RoutedEventArgs c(DependencyObject A_0, TaskbarIcon A_1)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs(aq, A_1);
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private static void c(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
        {
            ((TaskbarIcon) A_0).c(A_1);
        }

        public static void c(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.a(A_0, aq, A_1);
        }

        private void d()
        {
            lock (this)
            {
                if (!this.aj())
                {
                    if (!Util.a(ref this.at, q.a, g.c | g.b | g.a))
                    {
                        throw new Win32Exception("Could not create icon data");
                    }
                    this.f();
                    this.au.a((j) this.at.k);
                    this.e(true);
                }
            }
        }

        private void d(bool A_0)
        {
            if (this.au() != null)
            {
                if (A_0)
                {
                    if (!this.j() && !this.m().Handled)
                    {
                        this.au().IsOpen = true;
                        if (this.l() != null)
                        {
                            c((DependencyObject) this.l());
                        }
                        this.ay();
                    }
                }
                else if (!this.af().Handled)
                {
                    if (this.l() != null)
                    {
                        b((DependencyObject) this.l());
                    }
                    this.au().IsOpen = false;
                    this.y();
                }
            }
        }

        internal static RoutedEventArgs d(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = an
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private void d(DependencyPropertyChangedEventArgs A_0)
        {
            if (A_0.OldValue != null)
            {
                a((DependencyObject) A_0.OldValue, (TaskbarIcon) null);
            }
            if (A_0.NewValue != null)
            {
                a((DependencyObject) A_0.NewValue, this);
            }
            this.g();
        }

        public void d(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ad, A_0);
        }

        private static void d(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
        {
            ((TaskbarIcon) A_0).d(A_1);
        }

        public static void d(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.b(A_0, aq, A_1);
        }

        public void Dispose()
        {
            this.a(true);
            GC.SuppressFinalize(this);
        }

        private void e()
        {
            this.e(false);
            this.d();
        }

        internal static RoutedEventArgs e(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = am
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private void e(DependencyPropertyChangedEventArgs A_0)
        {
            this.i();
            if (A_0.OldValue != null)
            {
                a((DependencyObject) A_0.OldValue, (TaskbarIcon) null);
            }
            if (A_0.NewValue != null)
            {
                a((DependencyObject) A_0.NewValue, this);
            }
            this.h();
        }

        public void e(RoutedEventHandler A_0)
        {
            base.AddHandler(ac, A_0);
        }

        private static void e(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
        {
            ((TaskbarIcon) A_0).e(A_1);
        }

        public static void e(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.a(A_0, ap, A_1);
        }

        private void f()
        {
            this.at.k = 4;
            bool flag = o.Shell_NotifyIcon(q.e, ref this.at);
            if (!flag)
            {
                this.at.k = 3;
                flag = Util.a(ref this.at, q.e);
            }
            if (!flag)
            {
                this.at.k = 0;
                flag = Util.a(ref this.at, q.e);
            }
        }

        internal static RoutedEventArgs f(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = al
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private void f(DependencyPropertyChangedEventArgs A_0)
        {
            if ((this.au() == null) || (this.au().Content is string))
            {
                this.i();
            }
            this.h();
        }

        public void f(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ae, A_0);
        }

        private static void f(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
        {
            ((TaskbarIcon) A_0).f(A_1);
        }

        public static void f(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.b(A_0, ap, A_1);
        }

        ~TaskbarIcon()
        {
            this.a(false);
        }

        private void g()
        {
            Popup popup = this.ab() as Popup;
            if ((popup == null) && (this.ab() != null))
            {
                popup = new Popup {
                    AllowsTransparency = true,
                    PopupAnimation = PopupAnimation.None,
                    Child = this.ab(),
                    Placement = PlacementMode.AbsolutePoint,
                    StaysOpen = false
                };
            }
            if (popup != null)
            {
                this.a(popup, null, base.DataContext);
            }
            this.b(popup);
        }

        internal static RoutedEventArgs g(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ak
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        private void g(DependencyPropertyChangedEventArgs A_0)
        {
            ImageSource newValue = (ImageSource) A_0.NewValue;
            if (!Util.b())
            {
                this.a(newValue.a());
            }
        }

        public void g(RoutedEventHandler A_0)
        {
            base.AddHandler(w, A_0);
        }

        private static void g(DependencyObject A_0, DependencyPropertyChangedEventArgs A_1)
        {
            ((TaskbarIcon) A_0).g(A_1);
        }

        public static void g(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.a(A_0, ao, A_1);
        }

        private void h()
        {
            this.at.g = this.aa();
            if (((this.au.e() == j.c) && string.IsNullOrEmpty(this.at.g)) && (this.au() != null))
            {
                this.at.g = "ToolTip";
            }
            Util.a(ref this.at, q.b, g.c);
        }

        internal static RoutedEventArgs h(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = aj
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void h(RoutedEventHandler A_0)
        {
            base.RemoveHandler(af, A_0);
        }

        public static void h(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.b(A_0, ao, A_1);
        }

        private void i()
        {
            ToolTip tip = this.l() as ToolTip;
            if ((tip == null) && (this.l() != null))
            {
                tip = new ToolTip {
                    Placement = PlacementMode.Mouse,
                    HasDropShadow = false,
                    BorderThickness = new Thickness(0.0),
                    Background = System.Windows.Media.Brushes.Transparent,
                    StaysOpen = true,
                    Content = this.l()
                };
            }
            else if ((tip == null) && !string.IsNullOrEmpty(this.aa()))
            {
                tip = new ToolTip {
                    Content = this.aa()
                };
            }
            if (tip != null)
            {
                this.a(tip, null, base.DataContext);
            }
            this.a(tip);
        }

        internal static RoutedEventArgs i(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ai
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void i(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ab, A_0);
        }

        public static void i(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.a(A_0, an, A_1);
        }

        internal static RoutedEventArgs j(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ah
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void j(RoutedEventHandler A_0)
        {
            base.AddHandler(af, A_0);
        }

        public static void j(DependencyObject A_0, RoutedEventHandler A_1)
        {
            RoutedEventHelper.b(A_0, an, A_1);
        }

        protected RoutedEventArgs k()
        {
            return j(this);
        }

        internal static RoutedEventArgs k(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ag
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void k(RoutedEventHandler A_0)
        {
            base.RemoveHandler(w, A_0);
        }

        internal static RoutedEventArgs l(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = af
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void l(RoutedEventHandler A_0)
        {
            base.RemoveHandler(y, A_0);
        }

        protected RoutedEventArgs m()
        {
            return g(this);
        }

        internal static RoutedEventArgs m(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ae
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void m(RoutedEventHandler A_0)
        {
            base.RemoveHandler(aa, A_0);
        }

        protected RoutedEventArgs n()
        {
            RoutedEventArgs args = q(this);
            this.x().a(this.s(), this.ak() ?? this);
            return args;
        }

        internal static RoutedEventArgs n(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ad
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void n(RoutedEventHandler A_0)
        {
            base.RemoveHandler(aj, A_0);
        }

        internal static RoutedEventArgs o(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ac
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void o(RoutedEventHandler A_0)
        {
            base.AddHandler(ag, A_0);
        }

        private void OnExit(object A_0, EventArgs A_1)
        {
            this.Dispose();
        }

        protected RoutedEventArgs p()
        {
            return o(this);
        }

        internal static RoutedEventArgs p(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = ab
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void p(RoutedEventHandler A_0)
        {
            base.AddHandler(x, A_0);
        }

        protected RoutedEventArgs q()
        {
            return u(this);
        }

        internal static RoutedEventArgs q(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = aa
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void q(RoutedEventHandler A_0)
        {
            base.AddHandler(ai, A_0);
        }

        public void r()
        {
            if (!this.an())
            {
                if (!Application.Current.Dispatcher.CheckAccess())
                {
                    Action method = new Action(this.r);
                    Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, method);
                }
                else
                {
                    lock (this)
                    {
                        this.ax.Change(-1, -1);
                        Popup popup = this.z();
                        if (popup != null)
                        {
                            UIElement child = popup.Child;
                            if (!b(child, this).Handled)
                            {
                                popup.IsOpen = false;
                                if (child != null)
                                {
                                    a(child, (TaskbarIcon) null);
                                }
                            }
                            this.a((Popup) null);
                        }
                    }
                }
            }
        }

        internal static RoutedEventArgs r(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = z
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void r(RoutedEventHandler A_0)
        {
            base.RemoveHandler(x, A_0);
        }

        internal static RoutedEventArgs s(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = y
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void s(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ah, A_0);
        }

        protected RoutedEventArgs t()
        {
            return l(this);
        }

        internal static RoutedEventArgs t(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = x
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void t(RoutedEventHandler A_0)
        {
            base.AddHandler(ah, A_0);
        }

        protected RoutedEventArgs u()
        {
            return n(this);
        }

        internal static RoutedEventArgs u(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = w
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void u(RoutedEventHandler A_0)
        {
            base.AddHandler(ae, A_0);
        }

        internal static RoutedEventArgs v(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = v
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void v(RoutedEventHandler A_0)
        {
            base.RemoveHandler(ag, A_0);
        }

        public void w()
        {
            this.b();
            this.at.j = this.at.l = string.Empty;
            Util.a(ref this.at, q.b, g.e);
        }

        internal static RoutedEventArgs w(DependencyObject A_0)
        {
            if (A_0 == null)
            {
                return null;
            }
            RoutedEventArgs args = new RoutedEventArgs {
                RoutedEvent = u
            };
            RoutedEventHelper.a(A_0, args);
            return args;
        }

        public void w(RoutedEventHandler A_0)
        {
            base.AddHandler(aa, A_0);
        }

        public void x(RoutedEventHandler A_0)
        {
            base.AddHandler(ad, A_0);
        }

        protected RoutedEventArgs y()
        {
            return f(this);
        }

        public void y(RoutedEventHandler A_0)
        {
            base.AddHandler(z, A_0);
        }

        public void z(RoutedEventHandler A_0)
        {
            base.AddHandler(aj, A_0);
        }

        public Popup CustomBalloon
        {
            get
            {
                return (Popup) base.GetValue(g);
            }
        }

        public ICommand DoubleClickCommand
        {
            get
            {
                return (ICommand) base.GetValue(o);
            }
            set
            {
                base.SetValue(o, value);
            }
        }

        public object DoubleClickCommandParameter
        {
            get
            {
                return base.GetValue(p);
            }
            set
            {
                base.SetValue(p, value);
            }
        }

        public IInputElement DoubleClickCommandTarget
        {
            get
            {
                return (IInputElement) base.GetValue(q);
            }
            set
            {
                base.SetValue(q, value);
            }
        }

        [Browsable(false)]
        public System.Drawing.Icon Icon
        {
            get
            {
                return this.h;
            }
            set
            {
                this.h = value;
                this.at.f = (value == null) ? IntPtr.Zero : this.h.Handle;
                Util.a(ref this.at, q.b, g.b);
            }
        }

        [Category("NotifyIcon"), Description("Sets the displayed taskbar icon.")]
        public ImageSource IconSource
        {
            get
            {
                return (ImageSource) base.GetValue(i);
            }
            set
            {
                base.SetValue(i, value);
            }
        }

        public bool IsDisposed
        {
            [CompilerGenerated]
            get
            {
                return this.az;
            }
            [CompilerGenerated]
            private set
            {
                this.az = value;
            }
        }

        private bool IsPopupOpen
        {
            get
            {
                Popup popup = this.ar();
                ContextMenu contextMenu = base.ContextMenu;
                Popup popup2 = this.z();
                if (((popup == null) || !popup.IsOpen) && ((contextMenu == null) || !contextMenu.IsOpen))
                {
                    return ((popup2 != null) && popup2.IsOpen);
                }
                return true;
            }
        }

        public bool IsTaskbarIconCreated
        {
            [CompilerGenerated]
            get
            {
                return this.ay;
            }
            [CompilerGenerated]
            private set
            {
                this.ay = value;
            }
        }

        public ICommand LeftClickCommand
        {
            get
            {
                return (ICommand) base.GetValue(r);
            }
            set
            {
                base.SetValue(r, value);
            }
        }

        public object LeftClickCommandParameter
        {
            get
            {
                return base.GetValue(s);
            }
            set
            {
                base.SetValue(s, value);
            }
        }

        public IInputElement LeftClickCommandTarget
        {
            get
            {
                return (IInputElement) base.GetValue(t);
            }
            set
            {
                base.SetValue(t, value);
            }
        }

        [Category("NotifyIcon"), Description("Defines what mouse events display the context menu.")]
        public PopupActivationMode MenuActivation
        {
            get
            {
                return (PopupActivationMode) base.GetValue(m);
            }
            set
            {
                base.SetValue(m, value);
            }
        }

        [Description("Defines what mouse events display the TaskbarIconPopup."), Category("NotifyIcon")]
        public PopupActivationMode PopupActivation
        {
            get
            {
                return (PopupActivationMode) base.GetValue(n);
            }
            set
            {
                base.SetValue(n, value);
            }
        }

        public bool SupportsCustomToolTips
        {
            get
            {
                return (this.au.e() == j.c);
            }
        }

        [Description("Alternative to a fully blown ToolTip, which is only displayed on Vista and above."), Category("NotifyIcon")]
        public string ToolTipText
        {
            get
            {
                return (string) base.GetValue(j);
            }
            set
            {
                base.SetValue(j, value);
            }
        }

        [Description("Displayed as a Popup if the user clicks on the taskbar icon."), Category("NotifyIcon")]
        public UIElement TrayPopup
        {
            get
            {
                return (UIElement) base.GetValue(l);
            }
            set
            {
                base.SetValue(l, value);
            }
        }

        [Category("NotifyIcon")]
        public Popup TrayPopupResolved
        {
            get
            {
                return (Popup) base.GetValue(c);
            }
        }

        [Category("NotifyIcon"), Description("Custom UI element that is displayed as a tooltip. Only on Vista and above")]
        public UIElement TrayToolTip
        {
            get
            {
                return (UIElement) base.GetValue(k);
            }
            set
            {
                base.SetValue(k, value);
            }
        }

        [Browsable(true), Bindable(true), Category("NotifyIcon")]
        public ToolTip TrayToolTipResolved
        {
            get
            {
                return (ToolTip) base.GetValue(e);
            }
        }
    }
}

